/******************************************************************************
 * Copyright 2023 The Apollo Authors. All Rights Reserved.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 *****************************************************************************/

#include "modules/canbus_vehicle/x3epro/protocol/light_horn_report_362.h"
#include "glog/logging.h"
#include "modules/drivers/canbus/common/byte.h"
#include "modules/drivers/canbus/common/canbus_consts.h"

namespace apollo {
namespace canbus {
namespace x3epro {

using ::apollo::drivers::canbus::Byte;

Lighthornreport362::Lighthornreport362() {}
const int32_t Lighthornreport362::ID = 0x362;

void Lighthornreport362::Parse(const std::uint8_t* bytes, int32_t length,
                         X3epro* chassis) const {
  chassis->mutable_light_horn_report_362()->set_emergencystop_status(emergencystop_status(bytes, length));
  chassis->mutable_light_horn_report_362()->set_brakelamp_status(brakelamp_status(bytes, length));
  chassis->mutable_light_horn_report_362()->set_turn_right_light_status(turn_right_light_status(bytes, length));
  chassis->mutable_light_horn_report_362()->set_turn_left_light_status(turn_left_light_status(bytes, length));
  chassis->mutable_light_horn_report_362()->set_horn_status(horn_status(bytes, length));
  chassis->mutable_light_horn_report_362()->set_daylamp_status(daylamp_status(bytes, length));
  chassis->mutable_light_horn_report_362()->set_headbeam_status(headbeam_status(bytes, length));
  chassis->mutable_light_horn_report_362()->set_positionlamp_status(positionlamp_status(bytes, length));
  chassis->mutable_light_horn_report_362()->set_froglamp_status(froglamp_status(bytes, length));
  chassis->mutable_light_horn_report_362()->set_highbeam_status(highbeam_status(bytes, length));
  chassis->mutable_light_horn_report_362()->set_projector_status(projector_status(bytes, length));
  chassis->mutable_light_horn_report_362()->set_light_sensor_enable(light_sensor_enable(bytes, length));
  chassis->mutable_light_horn_report_362()->set_warninglamp_status(warninglamp_status(bytes, length));
  chassis->mutable_light_horn_report_362()->set_cleanerrelay_105(cleanerrelay_105(bytes, length));
  chassis->mutable_light_horn_report_362()->set_sd_alivecounter(sd_alivecounter(bytes, length));
  chassis->mutable_light_horn_report_362()->set_ad_alivecounter(ad_alivecounter(bytes, length));
  chassis->mutable_light_horn_report_362()->set_checksum(checksum(bytes, length));
}

// config detail: {'bit': 6, 'enum': {0: 'EMERGENCYSTOP_STATUS_OFF', 1: 'EMERGENCYSTOP_STATUS_ON'}, 'is_signed_var': False, 'len': 1, 'name': 'EmergencyStop_Status', 'offset': 0.0, 'order': 'motorola', 'physical_range': '[0|0]', 'physical_unit': 'bit', 'precision': 1.0, 'type': 'enum'}
Light_horn_report_362::EmergencyStop_statusType Lighthornreport362::emergencystop_status(const std::uint8_t* bytes, int32_t length) const {
  Byte t0(bytes + 0);
  int32_t x = t0.get_byte(6, 1);

  Light_horn_report_362::EmergencyStop_statusType ret =  static_cast<Light_horn_report_362::EmergencyStop_statusType>(x);
  return ret;
}

// config detail: {'bit': 7, 'enum': {0: 'BRAKELAMP_STATUS_OFF', 1: 'BRAKELAMP_STATUS_ON'}, 'is_signed_var': False, 'len': 1, 'name': 'brakelamp_status', 'offset': 0.0, 'order': 'motorola', 'physical_range': '[0|0]', 'physical_unit': 'bit', 'precision': 1.0, 'type': 'enum'}
Light_horn_report_362::Brakelamp_statusType Lighthornreport362::brakelamp_status(const std::uint8_t* bytes, int32_t length) const {
  Byte t0(bytes + 0);
  int32_t x = t0.get_byte(7, 1);

  Light_horn_report_362::Brakelamp_statusType ret =  static_cast<Light_horn_report_362::Brakelamp_statusType>(x);
  return ret;
}

// config detail: {'bit': 8, 'enum': {0: 'TURN_RIGHT_LIGHT_STATUS_OFF', 1: 'TURN_RIGHT_LIGHT_STATUS_ON'}, 'is_signed_var': False, 'len': 1, 'name': 'turn_right_light_status', 'offset': 0.0, 'order': 'motorola', 'physical_range': '[0|0]', 'physical_unit': 'bit', 'precision': 1.0, 'type': 'enum'}
Light_horn_report_362::Turn_right_light_statusType Lighthornreport362::turn_right_light_status(const std::uint8_t* bytes, int32_t length) const {
  Byte t0(bytes + 1);
  int32_t x = t0.get_byte(0, 1);

  Light_horn_report_362::Turn_right_light_statusType ret =  static_cast<Light_horn_report_362::Turn_right_light_statusType>(x);
  return ret;
}

// config detail: {'bit': 9, 'enum': {0: 'TURN_LEFT_LIGHT_STATUS_OFF', 1: 'TURN_LEFT_LIGHT_STATUS_ON'}, 'is_signed_var': False, 'len': 1, 'name': 'turn_left_light_status', 'offset': 0.0, 'order': 'motorola', 'physical_range': '[0|0]', 'physical_unit': 'bit', 'precision': 1.0, 'type': 'enum'}
Light_horn_report_362::Turn_left_light_statusType Lighthornreport362::turn_left_light_status(const std::uint8_t* bytes, int32_t length) const {
  Byte t0(bytes + 1);
  int32_t x = t0.get_byte(1, 1);

  Light_horn_report_362::Turn_left_light_statusType ret =  static_cast<Light_horn_report_362::Turn_left_light_statusType>(x);
  return ret;
}

// config detail: {'bit': 10, 'enum': {0: 'HORN_STATUS_OFF', 1: 'HORN_STATUS_ON'}, 'is_signed_var': False, 'len': 1, 'name': 'horn_status', 'offset': 0.0, 'order': 'motorola', 'physical_range': '[0|0]', 'physical_unit': 'bit', 'precision': 1.0, 'type': 'enum'}
Light_horn_report_362::Horn_statusType Lighthornreport362::horn_status(const std::uint8_t* bytes, int32_t length) const {
  Byte t0(bytes + 1);
  int32_t x = t0.get_byte(2, 1);

  Light_horn_report_362::Horn_statusType ret =  static_cast<Light_horn_report_362::Horn_statusType>(x);
  return ret;
}

// config detail: {'bit': 11, 'enum': {0: 'DAYLAMP_STATUS_OFF', 1: 'DAYLAMP_STATUS_ON'}, 'is_signed_var': False, 'len': 1, 'name': 'daylamp_status', 'offset': 0.0, 'order': 'motorola', 'physical_range': '[0|0]', 'physical_unit': 'bit', 'precision': 1.0, 'type': 'enum'}
Light_horn_report_362::Daylamp_statusType Lighthornreport362::daylamp_status(const std::uint8_t* bytes, int32_t length) const {
  Byte t0(bytes + 1);
  int32_t x = t0.get_byte(3, 1);

  Light_horn_report_362::Daylamp_statusType ret =  static_cast<Light_horn_report_362::Daylamp_statusType>(x);
  return ret;
}

// config detail: {'bit': 12, 'enum': {0: 'HEADBEAM_STATUS_OFF', 1: 'HEADBEAM_STATUS_ON'}, 'is_signed_var': False, 'len': 1, 'name': 'headbeam_status', 'offset': 0.0, 'order': 'motorola', 'physical_range': '[0|0]', 'physical_unit': 'bit', 'precision': 1.0, 'type': 'enum'}
Light_horn_report_362::Headbeam_statusType Lighthornreport362::headbeam_status(const std::uint8_t* bytes, int32_t length) const {
  Byte t0(bytes + 1);
  int32_t x = t0.get_byte(4, 1);

  Light_horn_report_362::Headbeam_statusType ret =  static_cast<Light_horn_report_362::Headbeam_statusType>(x);
  return ret;
}

// config detail: {'bit': 13, 'enum': {0: 'POSITIONLAMP_STATUS_OFF', 1: 'POSITIONLAMP_STATUS_ON'}, 'is_signed_var': False, 'len': 1, 'name': 'positionlamp_status', 'offset': 0.0, 'order': 'motorola', 'physical_range': '[0|0]', 'physical_unit': 'bit', 'precision': 1.0, 'type': 'enum'}
Light_horn_report_362::Positionlamp_statusType Lighthornreport362::positionlamp_status(const std::uint8_t* bytes, int32_t length) const {
  Byte t0(bytes + 1);
  int32_t x = t0.get_byte(5, 1);

  Light_horn_report_362::Positionlamp_statusType ret =  static_cast<Light_horn_report_362::Positionlamp_statusType>(x);
  return ret;
}

// config detail: {'bit': 14, 'enum': {0: 'FROGLAMP_STATUS_OFF', 1: 'FROGLAMP_STATUS_ON'}, 'is_signed_var': False, 'len': 1, 'name': 'froglamp_status', 'offset': 0.0, 'order': 'motorola', 'physical_range': '[0|0]', 'physical_unit': 'bit', 'precision': 1.0, 'type': 'enum'}
Light_horn_report_362::Froglamp_statusType Lighthornreport362::froglamp_status(const std::uint8_t* bytes, int32_t length) const {
  Byte t0(bytes + 1);
  int32_t x = t0.get_byte(6, 1);

  Light_horn_report_362::Froglamp_statusType ret =  static_cast<Light_horn_report_362::Froglamp_statusType>(x);
  return ret;
}

// config detail: {'bit': 15, 'enum': {0: 'HIGHBEAM_STATUS_OFF', 1: 'HIGHBEAM_STATUS_ON'}, 'is_signed_var': False, 'len': 1, 'name': 'highbeam_status', 'offset': 0.0, 'order': 'motorola', 'physical_range': '[0|0]', 'physical_unit': 'bit', 'precision': 1.0, 'type': 'enum'}
Light_horn_report_362::Highbeam_statusType Lighthornreport362::highbeam_status(const std::uint8_t* bytes, int32_t length) const {
  Byte t0(bytes + 1);
  int32_t x = t0.get_byte(7, 1);

  Light_horn_report_362::Highbeam_statusType ret =  static_cast<Light_horn_report_362::Highbeam_statusType>(x);
  return ret;
}

// config detail: {'bit': 16, 'enum': {0: 'PROJECTOR_STATUS_OFF', 1: 'PROJECTOR_STATUS_ON'}, 'is_signed_var': False, 'len': 1, 'name': 'projector_status', 'offset': 0.0, 'order': 'motorola', 'physical_range': '[0|0]', 'physical_unit': 'bit', 'precision': 1.0, 'type': 'enum'}
Light_horn_report_362::Projector_statusType Lighthornreport362::projector_status(const std::uint8_t* bytes, int32_t length) const {
  Byte t0(bytes + 2);
  int32_t x = t0.get_byte(0, 1);

  Light_horn_report_362::Projector_statusType ret =  static_cast<Light_horn_report_362::Projector_statusType>(x);
  return ret;
}

// config detail: {'bit': 17, 'enum': {0: 'LIGHT_SENSOR_ENABLE_DISABLE', 1: 'LIGHT_SENSOR_ENABLE_ENABLE'}, 'is_signed_var': False, 'len': 1, 'name': 'light_sensor_enable', 'offset': 0.0, 'order': 'motorola', 'physical_range': '[0|0]', 'physical_unit': 'bit', 'precision': 1.0, 'type': 'enum'}
Light_horn_report_362::Light_sensor_enableType Lighthornreport362::light_sensor_enable(const std::uint8_t* bytes, int32_t length) const {
  Byte t0(bytes + 2);
  int32_t x = t0.get_byte(1, 1);

  Light_horn_report_362::Light_sensor_enableType ret =  static_cast<Light_horn_report_362::Light_sensor_enableType>(x);
  return ret;
}

// config detail: {'bit': 19, 'enum': {0: 'WARNINGLAMP_STATUS_OFF', 1: 'WARNINGLAMP_STATUS_ON'}, 'is_signed_var': False, 'len': 2, 'name': 'warninglamp_status', 'offset': 0.0, 'order': 'motorola', 'physical_range': '[0|0]', 'physical_unit': 'bit', 'precision': 1.0, 'type': 'enum'}
Light_horn_report_362::Warninglamp_statusType Lighthornreport362::warninglamp_status(const std::uint8_t* bytes, int32_t length) const {
  Byte t0(bytes + 2);
  int32_t x = t0.get_byte(2, 2);

  Light_horn_report_362::Warninglamp_statusType ret =  static_cast<Light_horn_report_362::Warninglamp_statusType>(x);
  return ret;
}

// config detail: {'bit': 20, 'enum': {0: 'CLEANERRELAY_105_OFF', 1: 'CLEANERRELAY_105_ON'}, 'is_signed_var': False, 'len': 1, 'name': 'cleanerrelay_105', 'offset': 0.0, 'order': 'motorola', 'physical_range': '[0|0]', 'physical_unit': 'bit', 'precision': 1.0, 'type': 'enum'}
Light_horn_report_362::Cleanerrelay_105Type Lighthornreport362::cleanerrelay_105(const std::uint8_t* bytes, int32_t length) const {
  Byte t0(bytes + 2);
  int32_t x = t0.get_byte(4, 1);

  Light_horn_report_362::Cleanerrelay_105Type ret =  static_cast<Light_horn_report_362::Cleanerrelay_105Type>(x);
  return ret;
}

// config detail: {'bit': 43, 'is_signed_var': False, 'len': 4, 'name': 'sd_alivecounter', 'offset': 0.0, 'order': 'motorola', 'physical_range': '[0|0]', 'physical_unit': 'bit', 'precision': 1.0, 'type': 'int'}
int Lighthornreport362::sd_alivecounter(const std::uint8_t* bytes, int32_t length) const {
  Byte t0(bytes + 5);
  int32_t x = t0.get_byte(0, 4);

  int ret = x;
  return ret;
}

// config detail: {'bit': 51, 'is_signed_var': False, 'len': 4, 'name': 'ad_alivecounter', 'offset': 0.0, 'order': 'motorola', 'physical_range': '[0|0]', 'physical_unit': 'bit', 'precision': 1.0, 'type': 'int'}
int Lighthornreport362::ad_alivecounter(const std::uint8_t* bytes, int32_t length) const {
  Byte t0(bytes + 6);
  int32_t x = t0.get_byte(0, 4);

  int ret = x;
  return ret;
}

// config detail: {'bit': 63, 'is_signed_var': False, 'len': 8, 'name': 'checksum', 'offset': 0.0, 'order': 'motorola', 'physical_range': '[0|0]', 'physical_unit': 'bit', 'precision': 1.0, 'type': 'int'}
int Lighthornreport362::checksum(const std::uint8_t* bytes, int32_t length) const {
  Byte t0(bytes + 7);
  int32_t x = t0.get_byte(0, 8);

  int ret = x;
  return ret;
}
}  // namespace x3epro
}  // namespace canbus
}  // namespace apollo
